home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 4.6 KB | 164 lines | [TEXT/KAHL] |
- /***********************************************************************************
- CRowColumnMgr.cp
-
- Copyright © 1994 B-Ray Software. All rights reserved.
- Developed using Symantec C++ 7.0 and Symantec's TCL library.
- Portions of this code courtesy Symantec, Inc.
-
- This code may be freely distributed as long as this notice remains. The code
- may not be used in any commercial software without the consent of B-Ray Software.
-
- ---
-
- Abstract class for child pane management. Basically, parent gets notified if
- a child changes size. When a child does, the parent updates its own size to
- reflect the new size of the family.
-
- ***********************************************************************************/
-
- #include "CRowColumnMgr.h"
-
-
- TCL_DEFINE_CLASS_M1( CRowColumnMgr, CFamily );
-
-
- /*
- * AdjustForChildChange method
- *
- * Handles repositioning of children and resizing of ourselves
- * when a child changes.
- */
-
- void CRowColumnMgr :: AdjustForChildChange( long changedIndex, Rect *delta )
- {
- if ( delta->right || delta->bottom ) {
- AdjustChildren( changedIndex, delta ); // reposition children
- ChangeSelf( changedIndex, delta ); // adjust ourselves now
- MakeChildrenValid( changedIndex ); // validate the areas that didn't change
- }
- }
-
-
- /*
- * AdjustChildren method
- *
- * Move the children up/down or left/right based on the delta contents.
- * Actual movement is restricted by AdjustDelta, provided by derived
- * classes.
- */
-
- void CRowColumnMgr :: AdjustChildren( long changedIndex, Rect *delta )
- {
- CPane *aChild;
- long index = GetNumberChildren();
- Rect rect = *delta;
-
- AdjustDelta( &rect ); // ignore irrelevant axis changes
- if ( rect.right || rect.bottom ) {
- while ( index > changedIndex ) {
- aChild = GetChildAtIndex( index )->ChildToPane(); // get access to CPane data/methods
- aChild->Prepare(); // ??? necessary ???
- aChild->Offset( rect.right, rect.bottom, FALSE ); // move pane to new location
- --index;
- }
- }
- }
-
-
- /*
- * MakeChildrenValid method
- *
- * After resizing a child and resizing ourselves, we may have caused some children
- * to be invalidated when they don't need to be. So, we walk thru our list of
- * children and ValidRect() their frames so that they don't redraw and flicker (ugh!)
- */
-
- void CRowColumnMgr :: MakeChildrenValid( long changedIndex )
- {
- CPane *aChild;
- LongRect anAperture;
- Rect validRect;
- long index = 1;
-
- while ( index < changedIndex ) {
- aChild = GetChildAtIndex( index )->ChildToPane(); // get access to CPane data/methods
- aChild->Prepare(); // ??? necessary ???
- aChild->GetAperture( &anAperture ); // get the visible rectangle of the pane
- aChild->FrameToQDR( &anAperture, &validRect ); // put into QD coordinates
- ValidRect( &validRect ); // tell Mac to ignore it on update
- ++index;
- }
- }
-
-
- /*
- * InsertChildAt method - OVERRIDE
- *
- * Inserts a child into the list of children at the given index. May move
- * other children panes.
- */
-
- void CRowColumnMgr :: InsertChildAt( CFamily *aChild, long index )
- {
- Rect delta = { 0, 0, 0, 0 };
- CPane *aPane = aChild->ChildToPane(); // gain access to CPane data/methods
-
- PositionChild( aPane, index ); // set pane at correct location within family
-
- CFamily::InsertChildAt( aChild, index ); // add child to list of children
-
- delta.bottom = aPane->height; // calculate change child addition will have on others
- delta.right = aPane->width;
- AdjustForChildChange( index, &delta ); // cycle thru list of children and update their position
- }
-
-
- /*
- * RemoveChild method
- *
- * Removes a child pane from the family unit. Adjust other children if necessary
- */
-
- void CRowColumnMgr :: RemoveChild( CFamily *aChild )
- {
- CPane *aPane = aChild->ChildToPane();
- long index;
- Rect delta = { 0, 0, 0, 0 };
- short aWidth, aHeight;
-
- index = FindChildIndex( aChild );
- if ( index > 0 ) {
- itsChildren->DeleteItem( index ); // remove child from family
- aChild->SetParent( NULL ); // don't want to here from child anymore
- aPane->GetLengths( &aWidth, &aHeight ); // set up change rect for rest of children
- delta.bottom = -aHeight;
- delta.right = -aWidth;
- AdjustForChildChange( index - 1, &delta ); // revise position of other children
- }
- }
-
-
- /*
- * ChildMessage method - OVERRIDE
- *
- * Handles reception of kRowColChildChanged message sent by a member child.
- */
-
- void CRowColumnMgr :: ChildMessage( CFamily *aChild, long message, void *param )
- {
- long index;
-
- index = FindChildIndex( aChild );
- if ( index > 0 ) {
- switch ( message ) {
- case kRowColChildChanged: // update children with new positions
- AdjustForChildChange( index, (Rect *)param );
- break;
-
- default: // maybe ancestor class can handle it
- CFamily::ChildMessage( aChild, message, param );
- break;
- }
- }
- }
-